﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Forms;

namespace KpiConfigProject.Manager
{
    /// <summary>
    /// 
    /// </summary>
    class KpiGroupManager : AbstractManager
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string GetSQL()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select * from ctbKpiGroup");
            return builder.ToString();
        }

        public DataTable GetList()
        {
            return base.GetList(GetSQL());
        }

        public bool SaveData(List<DataRowView> addRows, List<DataRowView> modRows, List<DataRowView> delRows, Dictionary<int, int> groupKpiId, Dictionary<int, int> groupDimId)
        {
            try
            {
                bool isSucc = false;
                isSucc = DataBase.DataBaseManager.InsertDataView(addRows);
                if (!isSucc)
                    return isSucc;
                isSucc = DataBase.DataBaseManager.UpdateDataView(modRows);
                if (!isSucc)
                    return isSucc;
                isSucc = DataBase.DataBaseManager.DeleteDataView(delRows);
                if (!isSucc)
                    return isSucc;



                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return false;
        }
    }
}
